import request from "../request";


// 获取当前登录用户信息
export const getAdminInfoApi = (): PromiseRes<AdminInfoRes> => request.get('/admin/info');

// 获取用户数据列表
export const getAdminListApi = (data: AdminQueryPageParams): PromiseRes<AdminListRes> => request.get('/admin/list', {params: data});

// 修改用户信息
export const updateAdminInfoApi = (id: number, data: AdminObjItf): PromiseRes => request.post(`/admin/update/${id}`, data)

// 获取用户的角色信息
export const getAdminRoleApi = (id: number): PromiseRes<RoleObjItf[]> => request.get(`/admin/role/${id}`)

// 给用户分配角色
export const updateAdminRoleApi = (data: { adminId: number, roleIds: number[] }): PromiseRes => request.post(`/admin/role/update?adminId=${data.adminId}&roleIds=${data.roleIds}`)

// 根据id获取用户
export const getAdminInfoByIdApi = (id: number): PromiseRes<AdminObjItf> => request.get(`/admin/${id}`)

// 新增用户
export const registerAdminApi = (data: AdminObjItf): PromiseRes<AdminObjItf> => request.post('/admin/register',data)


// 删除用户信息
export const deleteAdminInfoByIdApi = (id: number): PromiseRes => request.post(`/admin/delete/${id}`)
